/**
 * <copyright>
 * </copyright>
 *
 */
package lco.cRLanguage.impl;

import lco.cRLanguage.CRLanguagePackage;
import lco.cRLanguage.Declaration;
import lco.cRLanguage.ScalarDeclaration;
import lco.cRLanguage.VectorialDeclaration;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Declaration</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link lco.cRLanguage.impl.DeclarationImpl#getSd <em>Sd</em>}</li>
 *   <li>{@link lco.cRLanguage.impl.DeclarationImpl#getVd <em>Vd</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class DeclarationImpl extends MinimalEObjectImpl.Container implements Declaration
{
  /**
   * The cached value of the '{@link #getSd() <em>Sd</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getSd()
   * @generated
   * @ordered
   */
  protected ScalarDeclaration sd;

  /**
   * The cached value of the '{@link #getVd() <em>Vd</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getVd()
   * @generated
   * @ordered
   */
  protected VectorialDeclaration vd;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected DeclarationImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return CRLanguagePackage.Literals.DECLARATION;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public ScalarDeclaration getSd()
  {
    return sd;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetSd(ScalarDeclaration newSd, NotificationChain msgs)
  {
    ScalarDeclaration oldSd = sd;
    sd = newSd;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, CRLanguagePackage.DECLARATION__SD, oldSd, newSd);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setSd(ScalarDeclaration newSd)
  {
    if (newSd != sd)
    {
      NotificationChain msgs = null;
      if (sd != null)
        msgs = ((InternalEObject)sd).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - CRLanguagePackage.DECLARATION__SD, null, msgs);
      if (newSd != null)
        msgs = ((InternalEObject)newSd).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - CRLanguagePackage.DECLARATION__SD, null, msgs);
      msgs = basicSetSd(newSd, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, CRLanguagePackage.DECLARATION__SD, newSd, newSd));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public VectorialDeclaration getVd()
  {
    return vd;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetVd(VectorialDeclaration newVd, NotificationChain msgs)
  {
    VectorialDeclaration oldVd = vd;
    vd = newVd;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, CRLanguagePackage.DECLARATION__VD, oldVd, newVd);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setVd(VectorialDeclaration newVd)
  {
    if (newVd != vd)
    {
      NotificationChain msgs = null;
      if (vd != null)
        msgs = ((InternalEObject)vd).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - CRLanguagePackage.DECLARATION__VD, null, msgs);
      if (newVd != null)
        msgs = ((InternalEObject)newVd).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - CRLanguagePackage.DECLARATION__VD, null, msgs);
      msgs = basicSetVd(newVd, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, CRLanguagePackage.DECLARATION__VD, newVd, newVd));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case CRLanguagePackage.DECLARATION__SD:
        return basicSetSd(null, msgs);
      case CRLanguagePackage.DECLARATION__VD:
        return basicSetVd(null, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case CRLanguagePackage.DECLARATION__SD:
        return getSd();
      case CRLanguagePackage.DECLARATION__VD:
        return getVd();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case CRLanguagePackage.DECLARATION__SD:
        setSd((ScalarDeclaration)newValue);
        return;
      case CRLanguagePackage.DECLARATION__VD:
        setVd((VectorialDeclaration)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case CRLanguagePackage.DECLARATION__SD:
        setSd((ScalarDeclaration)null);
        return;
      case CRLanguagePackage.DECLARATION__VD:
        setVd((VectorialDeclaration)null);
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case CRLanguagePackage.DECLARATION__SD:
        return sd != null;
      case CRLanguagePackage.DECLARATION__VD:
        return vd != null;
    }
    return super.eIsSet(featureID);
  }

} //DeclarationImpl
